//
//  TBCReadingList.m
//  待定
//
//  Created by BoyaLee on 15/11/9.
//  Copyright © 2015年 BoyaLee. All rights reserved.
//

#import "TBCReadingList.h"

@interface TBCReadingList ()

@property (strong, nonatomic) NSMutableArray *arrayList;

@end

@implementation TBCReadingList

+ (instancetype)shareReadingList {
    
    static TBCReadingList *readingList = nil;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        readingList = [[TBCReadingList alloc] init];
        
    });
    
    return readingList;
    
}

- (void)getAllArray:(id)responceObject {
    
    NSDictionary *dic = responceObject;
    
    self.arrayList = [NSMutableArray arrayWithCapacity:0];
    
    NSArray *listArray = [[dic objectForKey:@"data"] objectForKey:@"list"];
    for (NSDictionary *dictionary in listArray) {
        
        TBCReadingList *reading = [[TBCReadingList alloc] init];
        reading.detail_id = [dictionary objectForKey:@"id"];
        reading.detail_coverimg = [dictionary objectForKey:@"coverimg"];
        reading.detail_name = [dictionary objectForKey:@"name"];
        reading.detail_title = [dictionary objectForKey:@"title"];
        reading.detail_content = [dictionary objectForKey:@"content"];
        
        [self.arrayList addObject:reading];
        
    }
    
    [self.delegate sendAllArray:self.arrayList];
    
}

@end
